import service from '../internal/service.js'

// 门店列表==========================
/**
 * [APIGetShopListData description] 获取门店列表
 * @param       {String} [keyWord=''] [description]
 * @param       {[type]} [pageSize=20 }]            [description]
 * @constructor
 */
export function APIGetShopListData ({ keyWord = '', page = 1, pageSize = 20 }) {
  return service({
    url: `api/corp-shops/?keyword=${keyWord}&page=${page}&page_size=${pageSize}`,
    method: 'get'
  })
}

/**
 * [APIChangeShop description]改变门店
 * @param       {[type]} shop [description]
 * @constructor
 */
export function APIChangeShopId ({ shop }) {
  return service({
    url: `api/shops/${shop}/set-default`,
    method: 'put'
  })
}

export function APIGetAccountList ({ page = '' }) {
  return service({
    url: `api/user?page=${page}`,
    method: 'get'
  })
}

// 创建账号==================
export function APICreateAccount (formdata) {
  const data = formdata
  return service({
    url: `api/user`,
    method: 'post',
    data
  })
}

export function APICanCreate ({userName}) {
  return service({
    url: `api/user-check?user_name=${userName}`,
    method: 'get'
  })
}

export function APICheckAccount ({ userid }) {
  return service({
    url: `api/user/${userid}`,
    method: 'get'
  })
}

export function APIDeleteAccount ({ userid }) {
  return service({
    url: `api/user/${userid}`,
    method: 'delete'
  })
}

export function APIEditAccount ({ userid, formdata }) {
  const data = formdata
  return service({
    url: `api/user/${userid}`,
    method: 'patch',
    data
  })
}

export function APICanCreateRole () {
  return service({
    url: `api/operable-roles`,
    method: 'get'
  })
}
